<%@ page contentType="text/html;charset=utf-8"%>
<%@ page
	import="java.io.*, java.sql.*, java.util.*, java.text.*, napal.*, util.*"%>
<%@ page import="org.apache.ibatis.*"%>
<%
	request.setCharacterEncoding("utf-8");
	String cmd = request.getParameter("cmd");
	String selectedCategory = request.getParameter("category");
	
	String id = "";
	if((String)session.getAttribute("managerID")!=null)
		id = (String)session.getAttribute("managerID");
	else if((String)session.getAttribute("userID")!=null)
		id = (String)session.getAttribute("userID");


%>
<%@ include file="./Header.jsp"%>
			</td>
		</TR>
		<TR HEIGHT="100">
		
		<td>
		<a href="RentalHistory_s.jsp" class="btn btn-link btn-small">대여이력조회<br></a><br><br>

	<%
		if ("연장".equals(cmd)) {
			int rentalID = Integer.parseInt(request
					.getParameter("rentalID"));
			RentalHome.ExtensionWait(rentalID);%>
			<script language=javascript>
							self.window.alert("기자재를 연장신청하였습니다.");
							location.href="RentalHistory_s.jsp";
				</script>
			
			<% 
		}
	%>
	<table class="table" width="100%">
		<Tr>
		<td>기자재번호</td>
			<td>대여날짜</td>
			<td>모델명</td>
			<td>대여기간</td>
			<td>대여상태</td>
			<td>연장신청</td>
		</Tr>
		<%
			for (EMR r : RentalHome.EMR(id)){
		%>
		<TR>
		<form onsubmit="return confirm('해당 기자재를 연장신청하시겠습니까?');">
		<TD><%=r.get기자재번호()%></td>
			<TD><%=r.get대여시작날짜()%></td>
			<td><%=r.get모델명()%></td>
			<td><%=r.get대여기간()%></td>
			<Td><%=r.get대여상태()%></td>
			<input type=hidden name="rentalID" value="<%=r.get대여번호()%>">
			<input type=hidden name="overdueNum" value="<%=r.get연장횟수()%>">
			<td>
				<%
					if (r.get대여상태().equals("승인대기")) {
				%><font color="red"><B>연장 대기중</B></font><%
 	} else if(!r.get대여상태().equals("반납완료")&&r.get연장횟수()!=1){
 		%>
 		<input name="cmd" class="btn btn-inverse"
				type=submit value="연장">
 		<%
 	}
 %>
				</form>
			</td>
		</TR>
		<%
			}
		%>
	</table>
	

	<%
			for (EMR r : RentalHome.getRentalWait(id)){
		%>
	<h1>대여승인 대기중 : <%=r.get모델명()%>(<%=r.get카테고리명()%>)</h1>
	<%} %>
	</TD>
</TR>

<TR HEIGHT="100">
<TD><%@ include file="./bottom.jsp"%></TD> 
</TR>
</TABLE>
</body>
</html>